package com.cykj.page01.servlet;
import com.alibaba.fastjson2.JSON;
import com.cykj.page01.MyHttpRequest;
import com.cykj.page01.MyHttpResponse;
import com.cykj.page01.dto.ResponseDTO;
import com.cykj.page01.service.impl.UserServiceImpl;
/**
 * @BelongsProject: MyTomcat
 * @BelongsPackage: com.cykj.page03.servlet
 * @Author: WWJ
 * @CreateTime: 2025-07-07 16:01
 * @Description: TODO
 * @Version: 1.0
 */


public class LoginServlet extends BaseServlet {
    @Override
    public void doGet(MyHttpRequest request, MyHttpResponse response) {
        doPost(request, response);
    }

    @Override
    public void doPost(MyHttpRequest request, MyHttpResponse response) {
       String acc =  request.getRequestParamToKey("account");
       String pwd =  request.getRequestParamToKey("password");
       System.out.println("传来"+acc);
       System.out.println("出来"+pwd);
        UserServiceImpl userService = new UserServiceImpl();
        ResponseDTO dto = userService.login(acc, pwd);
        response.write( JSON.toJSONBytes(dto));
    }
}
